<table id="krepoDbList" data-options="loadMsg:'数据加载中...',toolbar:'#krepoListToolbar',fit:true,striped:true,singleSelect:true,border:false"></table>
<div id="krepoListToolbar" style="padding:5px;">
	<a href="javascript:krepoClear()" class="easyui-linkbutton" iconCls="icon-undo">返回资源库</a>
</div>
	
<script type="text/javascript" src="cusy/js/repository.js"></script>
<script type="text/javascript">
$(function() {
	var paramData = $(krepPageNum).val().split(',');
	$(krepoDbList).datagrid({
		title: '['+paramData[1]+']数据源列表',
		columns: [[
			{field:'name', title:'连接名', halign:'center', width:200},
			{field:'type', title:'类型', halign:'center', width:100},
			{field:'host', title:'数据库主机名或者IP地址', halign:'center', width:200},
			{field:'port', title:'端口', halign:'center', width:100},
			{field:'databaseName', title:'数据库名称', halign:'center', width:160},
			{field:'username', title:'用户名', halign:'center', width:200},
			{field:'shared', title:'属性', halign:'center', width:45, formatter:function(value, row, index){
				if (row.shared) {
					return '<span style="color:red">共享</span>';
				}
				return '独享';
			}},
			{field:'password', title:'操作', halign:'center', align:'center', width:165, formatter:function(value, row, index){
				var html = '<a class="krepoDbShowPwd" href="javascript:krepoDbShowPwd(\''+value+'\')"><i class="fa fa-eye fa-lg"></i> 显示密码</a>';
				if (row.shared) {
					html += '<a class="krepoSharedDb" href="javascript:krepoCloseSharedDb(\''+row.name+'\')"><i class="fa fa-unlink fa-lg"></i> 取消共享</a>'
				} else {
					html += '<a class="krepoSharedDb" href="javascript:krepoSharedDb(\''+row.name+'\')"><i class="fa fa-link fa-lg"></i> 共享</a>'
				}
				return html;
			}}
		]],
		loader: function(param, success, error) {
			$.get(reqRoute.getDatabasesByRepId, { repId: paramData[0] }, function(resultData) {
				success(resultData);
			});
		},
		loadFilter: function(resultData) {
			if (resultData.status == successCode) {
				return (null == resultData.data ? [] : resultData.data);
			} else {
				return { "status": resultData.status, "message": resultData.message, "rows": [] };
			}
		},
		onClickRow: datagridRowUnselect,
		onLoadSuccess: function(resultData) {
			datagridReqErr(this, resultData, 'name', 8);
			$(".krepoDbShowPwd").linkbutton({height: 25, plain: true});
			$(".krepoSharedDb").linkbutton({height: 25, plain: true});
		}
	});
});
</script>